package com.glodon.paas.account.web.util;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.springframework.web.filter.DelegatingFilterProxy;

public class SkippableDelegatingFilterProxy extends DelegatingFilterProxy {
    private static final String SKIPPED_SUFFIX = ".SKIPPED";

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
            throws ServletException, IOException {
        if (request.getAttribute(getFilterName() + SKIPPED_SUFFIX) != null)
            filterChain.doFilter(request, response);
        else
            super.doFilter(request, response, filterChain);
    }
}
